#lang "fblite"

Option Dynamic
Dim limit as Integer
limit = 99999

Dim sievearr(limit) as Integer
Dim primenumbers(limit) as Integer
Dim i as Integer
Dim x as Integer
Dim varStep as Integer
Dim primepos as Integer
primepos = 0
For i = 2 To limit+2
	sievearr(i-2) = i
Next i

For i = 0 to limit
	if sievearr(i) = 0 then
		continue for
	end if
	varstep = sievearr(i)
	for x = i+varstep to limit step varstep
		if sievearr(x) <> 0 then
			sievearr(x) = 0
		end if
	next x
Next i

for i = 0 to limit
	if sievearr(i) <> 0 then
		primenumbers(primepos) = sievearr(i)
		primepos = primepos + 1
	end if
next i

print primenumbers(primepos-1)
